﻿#include "WgtSqlStatus.h"

#pragma execution_character_set("utf-8")

WgtOneSqlStatus::WgtOneSqlStatus(const QString& name, QWidget *parent)
    : QWidget{parent}
{
    QHBoxLayout* hLayout = new QHBoxLayout();
    this->setLayout(hLayout);
    lblStatus = new QLabel(tr("正常"));
    hLayout->addWidget(new QLabel(name));
    hLayout->addWidget(lblStatus);
}

void WgtOneSqlStatus::setText(const QString& status)
{
    lblStatus->setText(status);
}

WgtSqlStatus::WgtSqlStatus(const QString& title, QWidget *parent)
    : QGroupBox{title, parent}
{
    this->setMinimumWidth(200);
    mLayout = new QVBoxLayout();
    this->setLayout(mLayout);
}

void WgtSqlStatus::removeOne(QString name)
{
    WgtOneSqlStatus* wgt = mMapWgtSqlStatus.take(name);
    wgt->deleteLater();
    wgt = nullptr;
}

void WgtSqlStatus::setStatus(QString name, QString status)
{
    mMapWgtSqlStatus.value(name)->setText(status);
}

void WgtSqlStatus::addOne(QString name)
{
    WgtOneSqlStatus* wgt = new WgtOneSqlStatus(name);
    mMapWgtSqlStatus.insert(name, wgt);
    mLayout->addWidget(wgt);
}


